package LanQiao._14JavaB;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class _1幸运数字 {
    public static void main(String[] args) {
        int count = 0;
        int res = 0;
        int index = 1;
        boolean flag = true;
        int n = 2023;
        while (count != n){
            List<Integer> helper = helper(index);
            for (Integer i : helper) {
                if (index % i != 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                count++;
                if (count == n) {
                    res = index;
                }
            }
            index++;
            flag = true;
        }
        System.out.println(res);
    }

    public static List<Integer> helper(int num){
        ArrayList<Integer> arrayList = new ArrayList<>();
        //126
        int sum = 0;
        int temp = num;
        int[] arr = new int[]{2,8,10,16};
        for (int i : arr) {
            while (temp != 0){
                sum += temp % i;
                temp /= i;
            }
            arrayList.add(sum);
            temp = num;
            sum = 0;
        }
        return arrayList;
    }
}
